{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib2 import Path\n",
    "p = Path(r'C:\\Users\\86159\\Desktop\\新建文件夹')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[path for path in p.iterdir() if path.is_file()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[WindowsPath('C:/Users/86159/Desktop/新建文件夹/Modern_GUI_PyDracula_PySide6_or_PyQt6'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/pyqt'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/PyQt-Fluent-Widgets'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/PyQt-Fluent-Widgets-PySide6'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/PySide6-codes'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/《Python GUI设计PyQt5从入门到实践》'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/独自开软著')]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[path for path in p.iterdir() if ~path.is_file()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[WindowsPath('C:/Users/86159/Desktop/新建文件夹/Modern_GUI_PyDracula_PySide6_or_PyQt6'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/pyqt'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/PyQt-Fluent-Widgets'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/PyQt-Fluent-Widgets-PySide6'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/PySide6-codes'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/《Python GUI设计PyQt5从入门到实践》'),\n",
       " WindowsPath('C:/Users/86159/Desktop/新建文件夹/独自开软著')]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "[path for path in p.iterdir() if path.is_dir()]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Modern_GUI_PyDracula_PySide6_or_PyQt6',\n",
       " 'pyqt',\n",
       " 'PyQt-Fluent-Widgets',\n",
       " 'PyQt-Fluent-Widgets-PySide6',\n",
       " 'PySide6-codes',\n",
       " '《Python GUI设计PyQt5从入门到实践》',\n",
       " '独自开软著']"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "floder_name_list = [str(path).split('\\\\')[-1] for path in p.iterdir() if path.is_dir()]\n",
    "floder_name_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Modern_GUI_PyDracula_PySide6_or_PyQt6',\n",
       " 'pyqt',\n",
       " 'PyQt-Fluent-Widgets',\n",
       " 'PyQt-Fluent-Widgets-PySide6',\n",
       " 'PySide6-codes',\n",
       " '《Python GUI设计PyQt5从入门到实践》',\n",
       " '独自开软著']"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "floder_name_list2 = [folder_name.split('\\\\')[-1] for folder_name in floder_name_list]\n",
    "floder_name_list2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "from time import sleep\n",
    "import numpy as np\n",
    "class Predictor:\n",
    "    def __init__(self, file_path=None):\n",
    "        self.file_path = file_path\n",
    "        self.data = np.arange(5)\n",
    "\n",
    "    def predict(self):\n",
    "        for index, value in enumerate(self.data):\n",
    "            sleep(1)\n",
    "            return int(index/len(self.data))\n",
    "        \n",
    "    def get_data(self):\n",
    "        i=1\n",
    "        while i < len(self.data):\n",
    "            sleep(1)\n",
    "            re = int(i/len(self.data)*100)\n",
    "            yield re\n",
    "            i += 1\n",
    "\n",
    "    def get_data2(self):\n",
    "        i=1\n",
    "        for i in self.data:\n",
    "            sleep(1)\n",
    "            yield i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 2, 3, 4])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p = Predictor()\n",
    "p.data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for number in p.get_data2():\n",
    "    print(number)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,\n",
       "       17, 18, 19, 20, 21, 22])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.arange(23)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
